/**
 *  *2010-7-11 上午12:03:53  add 
 */
package com.base.myproject.client.tools;

import com.base.myproject.client.busi.business.RatifyInfo;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * 常用的提交 
 * BaseRatify.getInstance().doratify(....); 进行提交
 * 提交审判的前提是已经做好了审判流程。
 * 
 * @author Administrator
 *2010-7-11
 * javazgw@gmail.com
 */
public class BaseRatify {

	static BaseRatify baseratify;
	public BaseRatify()
	{
		
	}
	
	public static BaseRatify getInstance()
	{
		if(baseratify==null)
			baseratify = new BaseRatify();
		
		return baseratify;
	}
	public void doratify(String busi,String icode,String flowname)
	{

		CommandSyncContainer list = new CommandSyncContainer();
		
		CommandSyncStartFlow ratifystart = new CommandSyncStartFlow();
		
		list.add(ratifystart);
		RatifyInfo ratifyinfo = new RatifyInfo();
		ratifyinfo.setBusi(busi);
		ratifyinfo.setIcode(icode);
		ratifyinfo.setFlowname(flowname);
		//ratifyinfo.getVariables().put("content", "to task2");
		ratifystart.setRatifyinfo(ratifyinfo);
		com.base.myproject.client.tools.GreetingServiceAsync greetingService = GWT
		.create(com.base.myproject.client.tools.GreetingService.class);
greetingService.SendCommandSync(list, new AsyncCallback<CommandSyncReturnObject> ()
		{

			@Override
			public void onFailure(Throwable caught) {
				
				MessageBox.alert("错误","网络连接错误，请重新尝试", null);
			}

			@Override
			public void onSuccess(
					CommandSyncReturnObject result) {
				if(result.isB())
				{
					Info.display("", "提交成功");
				}
				else
				{
					MessageBox.alert("错误", result.getMessage(), null);
				}
			}
	
		});
		
	
	}
}
